/**
 * 
 */
package com.lindenvalley.de;

import java.io.InputStream;

import android.app.Activity;
import android.content.Intent;
import android.os.AsyncTask;
import android.os.Bundle;

import com.lindenvalley.de.content.Sections;
import com.lindenvalley.de.network.WorkServer;
import com.lindenvalley.de.parsers.SimpleXmlParser;

/**
 * @author ruslan
 *
 */
public class SplashScreenActivity extends Activity {

	/* (non-Javadoc)
	 * @see android.app.Activity#onCreate(android.os.Bundle)
	 */
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		// TODO Auto-generated method stub
		super.onCreate(savedInstanceState);
		setContentView(R.layout.splash);
		
		AsyncTask<Object, Object, Object> task = new AsyncTask<Object, Object, Object>(){
			

			@Override
			protected Object doInBackground(Object... params) {
				// TODO Auto-generated method stub
				SimpleXmlParser<Sections> parser = new SimpleXmlParser<Sections>(Sections.class);				
		        InputStream is = getResources().openRawResource(R.raw.data);        
		        WorkServer.getInstance().setSections(parser.parse(is));
		        
		        
		        
		        
				
				return null;
			}
			
			@Override 
			protected void onPostExecute(Object result) {
		         Intent intent = new Intent(SplashScreenActivity.this, MainActivity.class);
		         startActivity(intent);
//		         SplashScreenActivity.this.finish();
		         finish();
		     }

			
		};
		task.execute(null, null, null);
		        

	}

}
